<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生信息维护</title>
<style type="text/css">
        .style1
        {
            width: 105px;
        }
        #Text4
        {
            width: 447px;
        }
        #TB_Addr
        {
            width: 450px;
        }
    </style>
<script language="JavaScript" src="../../../WF/Comm/JScript.js" type="text/javascript" ></script>
    <script type="text/javascript" src="../../../WF/Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../../WF/Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../../WF/Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />
    <link href="../../../DataUser/Style/table0.css" rel="stylesheet"  type="text/css" />
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../../WF/Comm/Gener.js"></script>
    <script type="text/javascript" src="../../../WF/Scripts/config.js"></script>
    <script type="text/javascript" >
    
    
    
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");
            //初始化groupID.
            var no = GetQueryString("No");
            /*
            *  首先要把初始化控件的代码写入到这里,不然会导致界面的批量赋值失败.
            */
            //调用公共类库的方法:  绑定枚举, 性别.
            GenerBindEnumKey("DDL_xb", "XB");
            //调用公共类库的方法: 绑定外键表. 班级.
            GenerBindEntities("DDL_fk_banji", "BP.Demo.BanJis");
            $.ajax({
                type: 'post',
                async: true,
                url: basePath+"/SDKFlowDemo/BPFramework/DataInputJQ/Student.do?DoType=Student_Init&No=" + no + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }
                    data = JSON.parse(data);
                    //单独给单选框赋值
                    var zzmmddl = data.zzmm;
                    $(":radio[name=DDL_ZZMM][value='"+zzmmddl+"']").attr("checked","true");

                    
                    //调用公共类库的方法:执行批量主表赋值
                    GenerFullAllCtrlsVal(data);
                    return;
                }
            });
          
            $("#Msg").html("");
        });
        
        function SaveAndNew() {
            this.Save();
            this.New();
        }
        

        
        function Save() {

            $("#Msg").html("正在保存,请稍后......");
            var no = GetQueryString("No");
            var checkBoxIDs = GenerCheckIDs(); //获得所有的 checkBox ID传入到后台去,用于解决checkbox控件，在没有被选择的时候，没有值的问题。
            var frmData = $("#cc").serialize();
            $.ajax({
                data: frmData,
                type: 'post',
                async: true,
                url:basePath+"/SDKFlowDemo/BPFramework/DataInputJQ/Student.do?DoType=Student_Save&CheckBoxIDs=" + checkBoxIDs + "&No=" + no + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') >= 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }
                    $("#Msg").html("<font color=green>" + data + "</font>");
                    var no = $('#TB_no').val();
                    window.location.href = 'student.htm?No=' + no;
                    return;
                }
            });
        }

    </script>
</head>
<body>
<form id="cc">
<table style="width:80%;">
<caption>学生信息卡片维护</caption>
<tr>
<td class="style1"> 学号</td>
<td> <input type="text" id="TB_no" /> </td>
<td> 姓名</td>
<td> <input type="text" id="TB_name" name="TB_Name" /> </td>
</tr>

<tr>
<td>性别</td>
<td>
<select name="DDL_XB" id="DDL_xb" > 
</select> 
</td>

<td> 政治面貌</td>
<td>

<!--  必须使用 RB_ 枚举值命名. -->

<input id="DDL_ZZMM_0" type="radio" name="DDL_ZZMM" value="0" checked="checked" /><label for="RB_ZZMM_0" >少先队员</label>
<input id="DDL_ZZMM_1" type="radio" name="DDL_ZZMM" value="1"  /><label for="RB_ZZMM_1">团员</label>
<input id="DDL_ZZMM_2" type="radio" name="DDL_ZZMM" value="2"  /><label for="RB_ZZMM_2">党员</label>
</td>
</tr>
<tr>
<td class="style1"> 电话</td>
<td><input type="text" id="TB_tel" name="TB_Tel" /> </td>
<td> 邮件</td>
<td> <input type="text" id="TB_email" name="TB_Email" /></td>
</tr>
<tr>
<td class="style1"> 地址</td>
<td colspan="3" ><input type="text" id="TB_addr" name="TB_Addr" /> </td>
</tr>
<tr>
<td>所在班级</td>
<td colspan=3>
<select name="DDL_FK_BanJi" id="DDL_fk_banji" > 
</select> 
 </td>
 </tr>
<tr>
<td > <input type="checkbox" value="" id="CB_isdushengzi" name="CB_IsDuShengZi" /><label for="CB_IsDuShengZi">是否是独生子？</label></td>
<td > <input type="checkbox" value="" id="CB_isjibing" name="CB_IsJiBing" /><label for="CB_IsJiBing">是否有重大疾病？</label></td>
<td > <input type="checkbox" value="" id="CB_ispianyuanshanqu" name="CB_IsPianYuanShanQu" /><label for="CB_IsPianYuanShanQu">是否偏远山区？</label></td>
<td > <input type="checkbox" value="" id="CB_istekunsheng" name="CB_IsTeKunSheng" /><label for="CB_IsTeKunSheng">是否是特困生？</label></td>
</tr>
<tr>
<td colspan="4">
<input type="button" value="新建" onclick="New()" id="Btn_New" />
<input type="button" value="保存" onclick="Save()" id="Btn_Save" />
<input type="button" value="保存并关闭" onclick="SaveAndClose()" id="Btn_SaveAndClose" />
<input type="button" value="保存并新建" onclick="SaveAndNew()" id="Btn_SaveAndNew" />
<input type="button" value="关闭" onclick="Close()" id="Btn_Close" />
<!-- <input type="button" value="删除" onclick="Delete()" id="Btn_Delete" /> -->
<div id="Msg"> </div>
<script type="text/javascript">
   

    function New() {
        window.location.href = 'student.htm';
    }
    
    function SaveAndClose() {
        this.Save();
        window.close();
    }
    function Close() {
        window.close();
    }
    function Delete() {
        var name = $("#TB_Name").val();
        if (window.confirm('您确定要删除['+name+']吗？') == false)
            return false;
        var no = $("#TB_No").val();
        $.ajax({
            type: 'post',
            async: true,
            url: basePath+"/SDKFlowDemo/BPFramework/DataInputJQ/Student.do?DoType=Student_Delete&No=" + no + "&m=" + Math.random(),
            dataType: 'html',
            success: function (data) {
                if (data.indexOf("err@") >= 0) {
                    alert(data);
                    return;
                }
                alert(data);
                window.close();
                return;
            }
        });
    }
</script>

</td>
</tr>
</table>



<fieldset>
<legend>开发约定与说明</legend>

<ul>
    
<li>需要对 /WF/Comm/Gener.js  进行引用.</li>
<li>控件的命名必须以 TB_ , DDL_, CB, RB_ 开头, 后半部分，必须与实体类的字段名称保持一致。</li>
<li>按钮必须以 Btn_ 开头, 常用的按钮名称需要保持一致，比如： Btn_Save  Btn_SaveAndClose , Btn_Close , Btn_Delete </li>
<li>常用的函数名必须保持一致，比如： Save()  SaveAncClose() Delete() Close() ...</li>
<li>每个控件的name 的值，都不能为空，否则会导致数据传递不过去，并且checkbox的ids 取不出来。</li>
<li>该界面是一个jq与bp框架的entity结合的实体信息存储，适用方面广，设计与实现比较容易，籍希望各位同事按照这个模式进行开发。</li>

</ul>

</fieldset> 

</form>
	
</body>
</html>